<!DOCTYPE html>
<html>
<head>
<script>
  if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
  }
  if (window.internals && window.eventSender) {
    internals.settings.setPreferCompositingToLCDTextEnabled(true);
    internals.setPageScaleFactorLimits(0.5, 4);

    addEventListener("load", function() {
      internals.setPageScaleFactor(0.5);
      setTimeout(function() {
        var layerTreeScaledDown = JSON.stringify(
            JSON.parse(internals.layerTreeAsText(document.getElementById("iframe").contentDocument)).layers);

        internals.setPageScaleFactor(1.5);
        setTimeout(function() {
          var layerTreeScaledUp = JSON.stringify(
              JSON.parse(internals.layerTreeAsText(document.getElementById("iframe").contentDocument)).layers);
          // Because logical size of the frame is unchanged, the layer tree in the frame should not be affected by the page scale.
          document.getElementById("result").innerText =
              layerTreeScaledUp == layerTreeScaledDown
                  ? "PASS"
                  : "FAIL\nScale 0.5:\n" + layerTreeScaledDown + "\nScale 1.5:\n" + layerTreeScaledUp;
          testRunner.notifyDone();
        }, 0);
      }, 0);
    }, false);
  }
</script>
</head>
<body>
<iframe id="iframe" src="resources/fixed-position-out-of-view-frame.html" style="width: 800px; height: 600px"></iframe>
<pre id="result"></pre>
</body>
</html>
